<?php
namespace app\user\controller;
use \Firebase\JWT\JWT;
use app\user\model\Member;
use think\Controller;
use think\facade\Cache;

class User
{
	// 后台注册功能
    public function register($username, $password, $email, $mobile = '',$scene='')
    {
		//创建包含用户信息的新数组
		$data = array(
			'username' => $username,
			'password' => $password,
			'email'    => $email,
			'mobile'   => $mobile,
		);

		if(empty($data['nickname'])){
			$data['nickname']=$username;
		}else{
			$data['nickname']=$nickname;
		}
		$data['update_time']=time();

		//验证手机
		if(empty($data['mobile'])){
			unset($data['mobile']);
		}

		// 调用验证数据validate
		$validate = new \app\user\validate\Member;

		if(!$validate->check($data)){

			return $validate->getError();
		}
		// 调用member模型
		$this->model = new Member();
		return $this->model->register($data,$scene);


    }
	// 后台用户登录功能
    public function login($username, $password,$type=1)
    {
		// 调用用户模型member
       $this->model = new Member();
       return $this->model->login($username, $password,$type);
    }

    
}
